V2EX  ›  英汉词典
Enqueued related words: Memory Address

Void Pointer

释义 / Definition

void pointer(void*):在 C/C++ 中指“无类型指针”,可以保存任意数据类型对象的地址。由于它不指向具体类型,不能直接解引用(dereference),通常需要先转换(cast)成正确的指针类型再使用。(在 C++ 中对类型安全要求更严格,常用 void* 做底层接口或与 C 交互。)

发音 / Pronunciation (IPA)

/vɔɪd ˈpɔɪntər/

例句 / Examples

In C, a void pointer can store the address of any object type.
在 C 语言中,void 指针可以存储任何对象类型的地址。

The API returns a void pointer that you must cast to the correct type before dereferencing, otherwise the program may have undefined behavior.
该 API 返回一个 void 指针,你必须在解引用之前把它转换成正确的类型,否则程序可能出现未定义行为。

词源 / Etymology

void 原意为“空的、无效的”,来源于法语并可追溯至拉丁语相关词根;在 C 语言里用来表示“无具体类型”(如 void 返回类型、void*)。pointer 来自 point(点、指向)加上表示“……的人/物”的后缀,合起来表示“指向某处地址的变量”。“void pointer”这一术语随 C 语言的类型系统与通用内存接口(如 malloc 返回 void*)而固定下来。

相关词 / Related Words

文学与作品举例 / Notable Works

  • The C Programming Language(Kernighan & Ritchie):介绍指针与通用指针用法的经典教材。
  • ISO/IEC 9899(C 语言标准,如 C11/C17):在标准文本中定义了 void* 的语义与转换规则。
  • The C++ Programming Language(Bjarne Stroustrup):讨论 void* 在 C++ 中的限制及与类型安全相关的设计取舍。
  • C Programming: A Modern Approach(K. N. King):以教学方式讲解 void*、内存分配与类型转换。
  • Effective C(Robert C. Seacord):强调 void* 与类型转换相关的安全与最佳实践。
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   726 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 19:39 · PVG 03:39 · LAX 11:39 · JFK 14:39
♥ Do have faith in what you're doing.